<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>


<!-- Mirrored from www.zi-han.net/theme/hplus/projects.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:19:44 GMT -->
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>H+ 后台主题UI框架 - 项目</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">

    <link href="/css/animate.min.css" rel="stylesheet">
    <link href="/css/style.min862f.css?v=4.1.0" rel="stylesheet">


</head>

<body class="gray-bg">

<div class="wrapper wrapper-content animated fadeInUp">
    <div class="row">
        <div class="col-sm-12">

            <div class="ibox">
                <div class="ibox-title">
                    <h5>所有动作</h5>
                    <div class="ibox-tools">
                        <a href="/userManager/addAction" class="btn btn-primary btn-xs">创建新动作</a>
                    </div>
                </div>
                <div class="ibox-content">


                    <div class="project-list">

                        <table class="table table-hover">
                            <tbody id="actionList">
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/content.min.js?v=1.0.0"></script>
<script>
    function deleteFuc(actionId) {
        var key = null;
        var v = document.cookie.split(";");
        for (var i = 0; i < v.length; i++) {
            var item = v[i].split("=");
            if (item[0] == 'easylink_user_token') {
                key = item[1];
                break;
            }
        }
        $.ajax({
            type: 'GET',
            url: '/action/deleteAction/' + actionId,
            headers: {
                'easylink_user_token': key
            },
            success: function (message) {
                alert('删除成功');

                function makeTable(actionId, type, name, msg) {
                    var data = "<tr>\n" +
                        "                                <td class=\"project-status\">\n" +
                        "                                    <span class=\"label label-primary\">" + type + "</span>\n" +
                        "                                </td>\n" +
                        "                                <td class=\"project-title\">\n" +
                        "                                    <a >" + name + "</a>\n" +
                        "                                    <br/>\n" +
                        "                                   <%-- <small>创建于 2014.08.15</small>--%>\n" +
                        "                                </td>\n" +
                        "                                <td>\n" +
                        "                                    <a>" + msg + "</a>\n" +
                        "                                    <br/>\n" +
                        "                                    <%-- <small>创建于 2014.08.15</small>--%>\n" +
                        "                                </td>\n" +
                        "                                <td class=\"project-actions\">\n" +
                        "                                    <a onclick='deleteFuc(" + actionId + ")' value='sb' class=\"btn btn-white btn-sm\"><i class=\"fa fa-folder\"></i> 删除 </a>\n" +
                        "                                    <a href=\"/userManager/editAction?actionId=" + actionId + "\" class=\"btn btn-white btn-sm\"><i class=\"fa fa-pencil\"></i> 编辑 </a>\n" +
                        "                                </td>\n" +
                        "                            </tr>";
                    return data;
                }

                //发送请求拿到用户名下所有的action
                $.ajax({
                    type: 'GET',
                    url: '/action/selectUserAction',
                    headers: {
                        'easylink_user_token': key
                    },
                    success: function (message) {
                        $('#actionList').empty();
                        var data = message.data;
                        var i = 0;
                        for (; i < data.length; i++) {
                            var item = data[i];
                            var type;
                            if (item.actionType == 1) type = "邮件";
                            if (item.actionType == 2) type = "短信";
                            if (item.actionType == 3) type = "APP";
                            $('#actionList').append(makeTable(item.actionId, type, item.actionName, item.actionDesc));
                        }
                    },
                    error: function (message) {
                        console.log(message);
                    }
                });
            },
            error: function (message) {
                console.log(message);
            }
        });
    }

    $(document).ready(function () {
        var key = null;
        var v = document.cookie.split(";");
        for (var i = 0; i < v.length; i++) {
            var item = v[i].split("=");
            if (item[0] == 'easylink_user_token') {
                key = item[1];
                break;
            }
        }


        function makeTable(actionId, type, name, msg) {
            var data = "<tr>\n" +
                "                                <td class=\"project-status\">\n" +
                "                                    <span class=\"label label-primary\">" + type + "</span>\n" +
                "                                </td>\n" +
                "                                <td class=\"project-title\">\n" +
                "                                    <a >" + name + "</a>\n" +
                "                                    <br/>\n" +
                "                                   <%-- <small>创建于 2014.08.15</small>--%>\n" +
                "                                </td>\n" +
                "                                <td>\n" +
                "                                    <a>" + msg + "</a>\n" +
                "                                    <br/>\n" +
                "                                    <%-- <small>创建于 2014.08.15</small>--%>\n" +
                "                                </td>\n" +
                "                                <td class=\"project-actions\">\n" +
                "                                    <a onclick='deleteFuc(" + actionId + ")' value='sb' class=\"btn btn-white btn-sm\"><i class=\"fa fa-folder\"></i> 删除 </a>\n" +
                "                                    <a href=\"/userManager/editAction?actionId=" + actionId + "\" class=\"btn btn-white btn-sm\"><i class=\"fa fa-pencil\"></i> 编辑 </a>\n" +
                "                                </td>\n" +
                "                            </tr>";
            return data;
        }

        //发送请求拿到用户名下所有的action
        $.ajax({
            type: 'GET',
            url: '/action/selectUserAction',
            headers: {
                'easylink_user_token': key
            },
            success: function (message) {
                console.log(message);
                var data = message.data;
                var i = 0;
                for (; i < data.length; i++) {
                    var item = data[i];
                    var type;
                    if (item.actionType == 1) type = "邮件";
                    if (item.actionType == 2) type = "短信";
                    if (item.actionType == 3) type = "APP";
                    $('#actionList').append(makeTable(item.actionId, type, item.actionName, item.actionDesc));
                }
            },
            error: function (message) {
                console.log(message);
            }
        });
        $("#loading-example-btn").click(function () {
            btn = $(this);
            simpleLoad(btn, true);
            simpleLoad(btn, false)
        })
    });

    function simpleLoad(btn, state) {
        if (state) {
            btn.children().addClass("fa-spin");
            btn.contents().last().replaceWith(" Loading")
        } else {
            setTimeout(function () {
                btn.children().removeClass("fa-spin");
                btn.contents().last().replaceWith(" Refresh")
            }, 2000)
        }
    };

</script>
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
</body>

<!-- Mirrored from www.zi-han.net/theme/hplus/projects.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:19:44 GMT -->
</html>

